<template>
    <div class="app-container">
        <el-dialog :title="title" :visible.sync="visible" width="1000px" v-if="visible" append-to-body
            :close-on-click-modal="false">
            <el-form ref="form" :model="form" :label-width="labelWidth">
                <el-form-item label="连锁资质：" prop="pictureList">
                    <ImageUploadMore :limit="6" :fileSize="20" :previewType="'2'" :deleteInquiry="true"
                        @successImg="getPictureList" :value="form.imgList">
                    </ImageUploadMore>
                </el-form-item>
            </el-form>
            <div slot="footer" class="dialog-footer">
                <!-- <el-button type="primary" @click="submitForm" :loading="sumitLoading">执行发放</el-button> -->
                <el-button @click="cancel">取 消</el-button>
            </div>
        </el-dialog>
    </div>
</template>
  
<script>
import {
    getToken
} from "@/utils/auth";
import {
    chainImgDetail, merchantChainImgRenew
} from "@/api/syChainManagement/syChainManagement.js";

export default {
    // dicts: ['asset_card_type'],
    name: "Dialog",
    props: {

    },
    data() {
        return {
            labelWidth: '150px',
            inputWidth: '320px',
            loading: false,
            sumitLoading: false,
            id: '', //连锁商家id
            // 弹出层标题
            title: "",
            // 是否显示弹出层
            visible: false,
            form: {
                chainId: '',//连锁商家id
                imgList: [],//连锁商家资质图片
            },

        };
    },
    created() {

    },
    methods: {
        /** 打开弹框 */
        open(id, name) {
            this.title = '企业名称：' + name
            this.form.chainId = id
            this.getChainImgDetail()
            this.visible = true
        },
        // 取消按钮
        cancel() {
            this.visible = false;
            // this.reset();
        },
        //获取资质图片
        getChainImgDetail() {
            chainImgDetail(this.form.chainId).then(response => {
                this.form = response.result
            }).catch(() => {
                
            });
        },
        getPictureList(e) {
            if (e != '') {
                this.form.imgList = e.split(",")
                // this.$refs['ruleForm'].clearValidate(['pictureList']);
            } else {
                this.form.imgList = []
            }
            this.submitForm()
        },
        /** 执行按钮 */
        submitForm() {
            merchantChainImgRenew(this.form).then(response => {
                this.$message.success('操作成功');
                this.getChainImgDetail()
            }).catch(() => {});
        },
    }
};

</script>
<style scoped>
.main {
    background-color: #fff;
    border-radius: 8px;
    padding: 20px 20px;
}

.icon_yes {
    font-size: 28px;
    color: #67c23a;
}

.img_list {
    display: flex;
    flex-wrap: wrap;
}

.img_list_box {
    display: flex;
    flex-wrap: wrap;
}

.img_list_box_demo {
    margin-right: 20px;
    margin-bottom: 20rpx;
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 20px;
}

.demo_image_preview {
    border: 1px dashed #d9d9d9;
    width: 120px;
    height: 120px;
    margin-bottom: 20px;
}


.avatar-uploader-icon {
    font-size: 28px;
    color: #8c939d;
    width: 120px;
    height: 120px;
    line-height: 120px;
    text-align: center;
    border: 1px dashed #d9d9d9;
}

.refuse_box {
    margin: 0 0 20px 20px;
}
</style>
  